package meihua.stopcarapp.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;
import meihua.mylibrary.base.BaseActivity;
import meihua.mylibrary.base.BaseFragmentAdapter;
import meihua.stopcarapp.R;
import meihua.stopcarapp.ui.fragment.FragmentFactory;

import static meihua.stopcarapp.ui.fragment.FragmentFactory.TAB_INDENT_SPEND;
import static meihua.stopcarapp.ui.fragment.FragmentFactory.TAB_INDENT_UEARNINGS;
import static meihua.stopcarapp.ui.fragment.FragmentFactory.TAB_INDENT_URECHANGE;

/**
 * Name: LGZ
 * Time: 2017/5/18.
 * Dec:
 */

public class ShareMoneyActivity extends BaseActivity {

    @Bind(R.id.activity_mywallet_tabs)
    TabLayout activityMywalletTabs;
    @Bind(R.id.activity_mywallet_pager)
    ViewPager activityMywalletPager;
    @Bind(R.id.toolbar_center)
    TextView toolbarCenter;

    private BaseFragmentAdapter mAdapter;

    private List<String> mTitle = new ArrayList<>();
    private List<Fragment> mFragments = new ArrayList<>();

    /**
     * 入口
     *
     * @param activity
     */
    public static void startAction(Activity activity) {
        Intent intent = new Intent(activity, ShareMoneyActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_share_money;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView(Bundle savedInstanceState) {
        toolbarCenter.setText("交易明细");
        mTitle.add("消费明细");
        mTitle.add("共享明细");
        mTitle.add("充值明细");
        mFragments.add(FragmentFactory.createFragment(TAB_INDENT_SPEND));
        mFragments.add(FragmentFactory.createFragment(TAB_INDENT_UEARNINGS));
        mFragments.add(FragmentFactory.createFragment(TAB_INDENT_URECHANGE));
        mAdapter = new BaseFragmentAdapter(getSupportFragmentManager(), mFragments, mTitle);
        activityMywalletPager.setAdapter(mAdapter);
        //为TabLayout设置ViewPager
        activityMywalletTabs.setupWithViewPager(activityMywalletPager);
        //使用ViewPager的适配器
        activityMywalletTabs.setTabsFromPagerAdapter(mAdapter);
    }

    @OnClick(R.id.toolbar_left)
    public void onViewClicked() {
    }
}
